/*
* Description: 窗口检测
*/

#ifndef APPLICATION_MONITOR_H
#define APPLICATION_MONITOR_H

#include "log.h"
#include <windows.h>
#include <WtsApi32.h>
#include <shlwapi.h>
#include <unordered_set>
#include "cJSON.h"

namespace GUEST {
class ApplicationMonitor {
public:
    const char* TRUE_STR = "1";
    const DWORD SUCCESS_EXIT_CODE = 0;
    void Init();
    bool IsApplicationOpenedInTaskBar();
    void SetSessionState(int32_t state);
    void Quit();
    bool InitWhiteListCollection();
    bool IsRunningApplicationInWhiteList();
private:
    std::string sessionName_ = "ApplicationMonitor";
    std::atomic<int32_t> sessionState_ = { WTS_SESSION_LOGON };
    void SetUsernameAndPath();
    std::string resultFilePath_ = "";
    bool isFilePathValid(const std::string &path);
    bool LoadWhiteListConfigFile(std::string& config);
    bool ParseConfigListToCollection(const char* data);
    std::unordered_set<std::wstring> applicationWhiteList_ = {};
};
#define APPLICATION_MONITOR SingletonNew<GUEST::ApplicationMonitor>::GetInstance()
}  //namespace GUEST
#endif